import React from 'react';

import Constants from '../../common/Constants';
import CommonSendFetchAction from '../common/CommonSendFetchAction';
import ResponseConstants from '../../common/ResponseConstants';

export default class PostRequestShoucangAction extends CommonSendFetchAction {
  constructor() {
    super();

    this.moduleType = Constants.MODULE_TYPE.POST;
    this.name = "PostRequestShoucangAction";
  }

  _dealCall(caller, data) {
    caller.setState({
      shoucangStatus: 2,
    })
  }

  _dealFinishSucess(data, response) {
    var str = "操作成功";
    if (this.data.is_favorited!=undefined) {
      str=this.data.is_favorited?"取消收藏":"收藏成功";
    }
    this.caller.setState({
      shoucangStatus: 1,
      statusText:str,
      updateByShoucang:true,
      isUpdateSomething:false
    })
  }

  _dealFinishFailed(data, response) {
    let detail = "服务器错误";
    if(data && data.detail != undefined) {
      detail = data.detail;
    }
    this.caller.setState({
      shoucangStatus:1,
      statusText:"操作失败:" + detail + " " + response.status,
      updateByShoucang:true,
      isUpdateSomething:false
    })
  }
}
